<?php

/**
 * Global ExceptionHandler
 *
 * @version 1.0
 * @package CMS
 */
class CMS_Error_Handler
{

    private function __construct()
    {
        super();
    }

    /**
     * Captures php errors and converts them into Exceptions
     *
     * @param int $errNo
     * @param string $errMessage
     * @param string $errFile
     * @param int $errLine
     *
     * @return boolean
     */
    public static function globalErrorHandler($errNo, $errMessage, $errFile, $errLine = NULL)
    {
        if (error_reporting() == 0)
            return;

        $errorType = array(
            E_ERROR => 'Error',
            E_WARNING => 'Warning',
            E_PARSE => 'Parsing Error',
            E_NOTICE => 'Notice',
            E_CORE_ERROR => 'Core Error',
            E_CORE_WARNING => 'Core Warning',
            E_COMPILE_ERROR => 'Compile Error',
            E_COMPILE_WARNING => 'Compile Warning',
            E_USER_ERROR => 'User Error',
            E_USER_WARNING => 'User Warning',
            E_USER_NOTICE => 'User Notice',
            E_STRICT => 'Runtime Notice',
            E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
        );

        throw new CMS_Exception(
            $errMessage . ' ' .
            $errFile . ' (' .
            $errLine . ')');

        return true;
    }

}

?>
